/**
 *
 */
function page() {
    /* this.pageMain = params.pageMain;
     this.nowPage = params.nowPage;
     // this.maxPage = params.maxPage;
     this.count = params.count;
     this.pageSize = params.pageSize;
     this.url = params.url;
     this.params = params.params;
     this.pakey = params.pakey;
     this.init();*/
}
/*page.prototype = {
 init: function () {
 var maxPage = 0;
 if (this.count % this.pageSize == 0) {
 maxPage = this.count / this.pageSize;
 } else {
 maxPage = parseInt(this.count / this.pageSize) + 1;
 }
 var id = this.pageMain;
 var pageDiv = $("#" + id);

 if (this.nowPage > 1) {

 pageDiv.html('<li ><a href="' + this.url + this.params + '&' + this.pakey + '=' + (this.nowPage - 1) + '" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>');
 var i = this.nowPage - 5;
 if (i < 1) {
 i = 1;
 }
 for (; i < this.nowPage; i++) {
 pageDiv.append('<li ><a href="' + this.url + this.params + '&' + this.pakey + '=' + i + '">' + i + ' <span class="sr-only">(current)</span></a></li>');
 }

 }

 pageDiv.append('<li class="active"><a>' + this.nowPage + ' <span class="sr-only">(current)</span></a></li>');
 if (this.nowPage < maxPage) {
 for (var i = this.nowPage + 1; i <= maxPage && i <= this.nowPage + 5; i++) {
 pageDiv.append('<li><a href="' + this.url + this.params + '&' + this.pakey + '=' + i + '">' + i + ' <span class="sr-only">(current)</span></a></li>');
 }
 pageDiv.append('<li><a href="' + this.url + this.params + '&' + this.pakey + '=' + (this.nowPage + 1) + '">&raquo; <span class="sr-only">(current)</span></a></li>');
 }
 }
 };*/
var url = null;
var params = null;

function tablePage(pno, psize, total, urll, paramss) {
    url = urll;
    params = paramss;
    var num = total;
    if (num > 0) {
        var totalPage = 0;
        var pageSize = psize;

        if (num / pageSize > parseInt(num / pageSize)) {
            totalPage = parseInt(num / pageSize) + 1;
        } else {
            totalPage = parseInt(num / pageSize);
        }
        var currentPage = pno;

        var pageEnd = document.getElementById("pageEnd");
        var tempStr = "<span class='page-describe'>共" + num + "条记录  分" + totalPage + "页 </span>";
        // var tempStr = "<span class='page-describe'>共" + num + "条记录 每页"+ pageSize+"条 分" + totalPage + "页 当前第" + currentPage + "页</span>";
        if (currentPage > 1) {
            tempStr += "&nbsp;&nbsp;<a href=# onClick=" + "goPage(" + (1) + "," + psize + ")>首页</a>";
            tempStr += "&nbsp;&nbsp;<a href=# onClick=" + "goPage(" + (currentPage - 1) + "," + psize + ")>上一页</a>"
        } else {
            tempStr += "&nbsp;&nbsp;首页";
            tempStr += "&nbsp;&nbsp;上一页";
        }
        if (currentPage >= 4 && totalPage > 5) {
            tempStr += "...";
        }
        if (totalPage <= 5) {
            for (var i = 1; i <= totalPage; i++) {
                if (currentPage == i) {
                    tempStr += "&nbsp;&nbsp;<span class=\"current\">" + i + "</span>";
                } else {
                    tempStr += "&nbsp;&nbsp;<a  href=# onClick=" + "goPage(" + i + "," + psize + ")>" + i + "</a>";
                }
            }
        } else if (currentPage <= 3) {
            for (var i = 1; i <= 4; i++) {
                if (currentPage == i) {
                    tempStr += "&nbsp;&nbsp;<span class=\"current\">" + i + "</span>";
                } else {
                    tempStr += "&nbsp;&nbsp;<a  href=# onClick=" + "goPage(" + i + "," + psize + ")>" + i + "</a>";
                }
            }
        } else if (currentPage >= totalPage - 2) {
            for (var i = totalPage - 3; i <= totalPage ; i++) {
                if (currentPage == i) {
                    tempStr += "&nbsp;&nbsp;<span class=\"current\">" + i + "</span>";
                } else {
                    tempStr += "&nbsp;&nbsp;<a  href=# onClick=" + "goPage(" + i + "," + psize + ")>" + i + "</a>";
                }
            }
        } else {
            tempStr += "&nbsp;&nbsp;<a  href=# onClick=" + "goPage(" + (currentPage - 1) + "," + psize + ")>" + (currentPage - 1) + "</a>";
            tempStr += "&nbsp;&nbsp;<span class=\"current\">" + currentPage + "</span>";
            tempStr += "&nbsp;&nbsp;<a  href=# onClick=" + "goPage(" + (currentPage + 1) + "," + psize + ")>" + (currentPage + 1) + "</a>";
        }

        if (currentPage < (totalPage - 2) && totalPage > 4) {
            tempStr += "&nbsp;&nbsp;...";
        }

        if (currentPage < totalPage) {
            tempStr += "&nbsp;&nbsp;<a href=# onClick=" + "goPage(" + (currentPage + 1) + "," + psize + ")>下一页</a>";
            tempStr += "&nbsp;&nbsp;<a href=# onClick=" + "goPage(" + (totalPage) + "," + psize + ")>尾页</a>";
        } else {
            tempStr += "&nbsp;&nbsp;下一页";
            tempStr += "&nbsp;&nbsp;尾页";
        }
    }else{
        tempStr="暂无数据!";
    }
// return tempStr;
    document.getElementById("table_info").innerHTML = tempStr;
}
function goPage(page, pageSize) {
    var loadUrl = url + params + "&&page=" + page + "&&pageSize=" + pageSize;
    $("#datamain", parent.document).attr("src", loadUrl);
}